# -*- encoding:utf8 -*-

import urllib2
from urllib2 import HTTPError,URLError
from bs4 import BeautifulSoup

if __name__ == "__main__":
    url1 = "https://movie.douban.com/top250"
    url2 = "http://www.sinb.com.cn/"
    try:
        response = urllib2.urlopen(url1).read()
    except HTTPError as e:
        print e

    soup = BeautifulSoup(response,"html.parser")
    try:
        print soup.title
        titles = soup.select("[class~=title]")
        # for item in titles:
        #     print item.string
    except AttributeError as e:
        print e.message